﻿using System;
using System.Collections.Generic;
using System.Web;

namespace ToaThuoc_PAK.Handler
{
    /// <summary>
    /// Summary description for XML_CachDungThuoc
    /// </summary>
    public class XML_CachDungThuoc : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            Thuoc Thuoc = new global::Thuoc();
            string xmlReturn = "<Root>";
            List<string> lst = Thuoc.LayCachDungThuoc();
            List<string> lstDVT = Thuoc.LayDonViDungThuoc();
            foreach (string item in lst)
            {
                xmlReturn += "<CachDungThuoc CachDung='" + item.Trim() + "'></CachDungThuoc> \n";
            }
            foreach (string item in lstDVT)
            {
                xmlReturn += "<DonViThuoc DonVi='" + item.Trim() + "'></DonViThuoc> \n";
            }
            xmlReturn += "</Root>";
            context.Response.ContentType = "text/xml";
            context.Response.Write(xmlReturn);
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }
}